package router

import (
	"jgt-oper/src/context"
	"jgt-oper/src/web"

	"github.com/facebookgo/inject"
	"github.com/teambition/gear"
)

// WebUserMap 注册路由映射
func WebUserMap(g *inject.Graph, r *gear.Router) {
	a := new(web.User)
	err := g.Provide(&inject.Object{Value: a})
	if err != nil {
		panic(err)
	}

	r.Get("/users/page", context.WrapContext(a.QueryPage))
	r.Get("/users/Count", context.WrapContext(a.Count))
	r.Get("/users/search", context.WrapContext(a.Search))
	r.Get("/users", context.WrapContext(a.Query))
	r.Get("/users/:id", context.WrapContext(a.Get))
	r.Put("/users/:id/unauth", context.WrapContext(a.CancelAuth))
	r.Put("/users/:id/writeoff", context.WrapContext(a.WriteOff))

	r.Put("/users/:id/:type/:act", context.WrapContext(a.ChangeBan))
}
